//
//  ZGLPlayResultTVC.m
//  Faker
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "ZGLPlayResultTVC.h"

@interface ZGLPlayResultTVC ()

@end

@implementation ZGLPlayResultTVC

-(void)viewWillAppear:(BOOL)animated {
    self.tabBarController.tabBar.hidden = YES;
    self.tableView.backgroundColor = foreColor;
    [self.tableView reloadData];
    
}

-(void)viewWillDisappear:(BOOL)animated {
    self.tabBarController.tabBar.hidden = NO;
}
#pragma mark 1 - 主程序入口
- (void)viewDidLoad {
    [super viewDidLoad];
}
#pragma mark 2- DataArray属性set方法重写
-(void)setDataArray:(NSArray *)dataArray {
    if (_dataArray != dataArray) {
        _dataArray = dataArray;
    }
    [self.tableView reloadData];
}
#pragma mark 3 - tableView部分
/* 分区数 */
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return self.dataArray.count;
}
/* 行数 */
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 1;
}
/* cell创建部分 */
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *str = @"ZGLPlayResultTVC_Cell";
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:str];
    }
    cell.textLabel.attributedText = [self.dataArray objectAtIndex:indexPath.section];
    if ([cell.textLabel.text isEqualToString:self.cityName]) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(330 * ScaleX, 12 * ScaleX, 20 * ScaleX, 20 *ScaleX)];
        imageView.image = [UIImage imageNamed:@"sdingyue"];
        [cell addSubview:imageView];
    }
    cell.backgroundColor = foreColor;
    return cell;
}
#pragma mark 4 - cell选中点击事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    /* 获取点击的cell */
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    /* 获取cell上面的值 */
    NSString *str = cell.textLabel.text;
    /* 通过协议方法传值 */
    [self.delegate passCityName:str];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
